/**
 * 获取指定日期时间集合
 * @param {Date} date
 * @returns ["YYYY-MM-DD", "HH:mm:ss"]
 */
export function toLocaleDateStringWithCustomFormat(date: Date = new Date()) {
  if (!(date instanceof Date)) return Error("date is not Date");
  const datePart = date
    .toLocaleDateString("zh-cn", {
      year: "numeric",
      month: "2-digit",
      day: "2-digit",
    })
    .replace(/\//g, "-");
  const timePart = date.toLocaleTimeString("zh-cn", {
    hour: "2-digit",
    minute: "2-digit",
    second: "2-digit",
    hour12: false,
  });
  return [datePart, timePart] as [string, string];
}